<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../base.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <section class="content-header">
        <h1>
            统计分析
            <small>厂家销量统计</small>
        </h1>
    </section>
    <section class="content">
        <div class="box box-primary">
            <div id="main" style="width: 600px;height:400px;"></div>
        </div>
    </section>
</div>
</body>
<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../../plugins/echarts/echarts.min.js"></script>
<script type="text/javascript">
   $.ajax({
       url:"/stat/getFactoryData.do",
       type:"get",
       dataType:"json",
       success:function(resultData){
           // 3.1 找到div
           var myChart = echarts.init(document.getElementById('main'));

           //3.2 准备报表图的数据
           option = {
               title: {
                   text: '某站点用户访问来源',
                   subtext: '纯属虚构',
                   left: 'center'
               },
               tooltip: {
                   trigger: 'item',
                   formatter: '{a} <br/>{b} : {c} ({d}%)'
               },
               legend: {
                   orient: 'vertical',
                   left: 'left',
                   data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
               },
               series: [
                   {
                       name: '访问来源',
                       type: 'pie',
                       radius: '55%',
                       center: ['50%', '60%'],
                       data: resultData,
                       emphasis: {
                           itemStyle: {
                               shadowBlur: 10,
                               shadowOffsetX: 0,
                               shadowColor: 'rgba(0, 0, 0, 0.5)'
                           }
                       }
                   }
               ]
           };



           // 3.3 把数据与div整合到一块
           myChart.setOption(option);

       }
   });
</script>
</html>